package com.yoki.cloud.common.code.mapper;

import java.sql.Types;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by SunnyWen on 2017/7/24.
 */
public class MySqlMapper {

    private static Map map = new HashMap() ;

    static{
        map.put(Types.BIGINT , Long.class) ;

        map.put(Types.SMALLINT , Integer.class) ;
        map.put(Types.INTEGER , Integer.class) ;
        map.put(Types.TINYINT , Integer.class) ;

        map.put(Types.BOOLEAN , Boolean.class) ;
        map.put(Types.BIT , Boolean.class) ;

        map.put(Types.CHAR , String.class) ;
        map.put(Types.VARCHAR , String.class) ;
        map.put(Types.LONGVARCHAR , String.class) ;
        map.put(Types.LONGNVARCHAR , String.class) ;
        map.put(Types.VARCHAR , String.class) ;

        map.put(Types.DATE , Date.class) ;
        map.put(Types.TIMESTAMP , Date.class) ;
        map.put(Types.TIME , Date.class) ;

        map.put(Types.DOUBLE , Double.class) ;
        map.put(Types.DECIMAL , Double.class) ;

        map.put(Types.FLOAT , Float.class) ;

        map.put(Types.BINARY , Byte[].class) ;
        map.put(Types.BLOB , Byte[].class) ;
    }

    public static Class getJavaType(Integer sqlType){
        Class clazz = (Class) map.get(sqlType);
        return clazz ;
    }

}
